\ Ideas:
\  Control Forth/Dorothy precedence inside methods:   [dorothy] [forth]

: test
   depth 1 = and if ." OK" cr exit then .s true s" FAIL" ?abort ;

cr .( Compiling some structures ... )

type: vector
   int.field x
   int.field y
   int.field z
end-type

vector extend: 4dvector
   int.field w
end-type

type: vertex2d
   short.field x
   short.field y
   short.field z
   short skip
   short.field u
   short.field v
   int.field color
end-type

type: indirect
   vertex2d.pointer v
end-type

type: more-indirect
   indirect.pointer io
end-type


cr .( Declaring objects...)
vertex2d.make v
vertex2d.make v2
indirect.make io
more-indirect.make io2
node.make container
node.make a
node.make b
node.make c



cr .( Declaring refs...)
v vertex2d.ref vref


cr .( Declaring array... )
100 vector.make[] vectors


cr .( Defining methods...)
method: more-indirect.clear
   io.v.x.clear
   io.v.y.clear
   io.v.z.clear
   ;

method: more-indirect.fill
   -1 io.v.x.!
   -1 io.v.y.!
   -1 io.v.z.!
   ;

method: more-indirect.busybody
   clear fill ;

cr .( Compiling a superclass's method...)

method: 4dvector.clear
   super clear  w.clear ;

0 value n
: tests
   cr
   ." - General Tests - "
   ." constref: " 123 v.z.! v.z.@ 123 = test
   ." field: " v.z  v vertex2d.z  = test
   ." indirect field: " 123 vref.z.!  vref.z.@ 123 = test
   ." change ref: " v2 to vref   v vref <> test
   ." pointer: " v2 to io.v  io.v v2 = test
   ." double-indirect field: " 987 io.v.z.!  io.v.z.@ 987 = test
   ." double-indirect pointer: " io to io2.io  io2.io io =   987 io2.io.v.z.!  io2.io.v.z.@ 987 =  and test
   ." method: "  123 io.v.z.!  456 io.v.z.!  987 io.v.z.!  io2.clear   io2.io.v.x.@ 0 =  io2.io.v.y.@ 0 =  io2.io.v.z.@ 0 =  and and  test
   ." nested methods: " io2.busybody  io2.io.v.x.@   io2.io.v.y.@   io2.io.v.z.@   and and  test
   cr
   ." -Collections- " cr
   ." ANY.[] - elements' fields "  0 vectors.[].z 99 vectors.[].z <>  99 vectors.[].x 99 vectors.[].z  <>  and  test
   ." ANY.NEXT " 0 vectors.[].next  1 vectors.[] = test
   ." ANY.LENGTH "  vectors.length 100 = test
   ." ANY.COUNT "  vectors.count  .s  swap vectors =  swap 100 vector sizeof * =  and  test
   ." ANY.S "  5 vector.s  5 vector sizeof *  =  test
   ." ANY.SOME:[ "  0 to n  3 vectors.some:[ . 1 +to n ;]  n 3 = test
   ." NODE.ADD " a container.add b container.add c container.add  container.first a =  container.last c = and  test
   ." NODE.EACH:[ " container.each:[ . ;]  true test
   ." NODE.REMOVE "  a.remove  b.remove  c.remove  container.first 0 =  container.last  0 =  and  test
   ." NODE.EACH:[ (empty): " container.each:[  .  ;]  true test
   ." NODE.ADD (jumble) "  a container.add b container.add c container.add b container.add a container.add c container.add c container.add b container.add a container.add c container.add a container.add b container.add a container.add b container.add c container.add
      container.first dup a =  swap node.next  dup  b =  swap  node.next  c =  and  and  test
   ." NODE.[] "  0 container.[] a =  1 container.[] b =  2 container.[] c =  and  and  test
   ;
tests
